package com.eisei.factory.tbl;

import javax.persistence.*;
import java.math.BigInteger;
import java.sql.Timestamp;
import java.util.Collection;

/**
 * Created by equipo.crea on 3/08/14.
 */
@Entity
@Table(name = "TBL_CAT_ROL", schema = "SIS_GES_CALIDAD", catalog = "")
public class TblCatRolEntity {
    private BigInteger pkCatRol;
    private String descRol;
    private Timestamp fechaAlta;
    private Timestamp fechaActualiza;
    private BigInteger fkCatEstatus;
    private TblCatEstatusEntity tblCatEstatusByFkCatEstatus;
    private Collection<TblRelGrupoRolEntity> tblRelGrupoRolsByPkCatRol;

    @Id
    @Column(name = "PK_CAT_ROL", nullable = false, insertable = true, updatable = true, length = 2, precision = 0)
    public BigInteger getPkCatRol() {
        return pkCatRol;
    }

    public void setPkCatRol(BigInteger pkCatRol) {
        this.pkCatRol = pkCatRol;
    }

    @Basic
    @Column(name = "DESC_ROL", nullable = true, insertable = true, updatable = true, length = 30, precision = 0)
    public String getDescRol() {
        return descRol;
    }

    public void setDescRol(String descRol) {
        this.descRol = descRol;
    }

    @Basic
    @Column(name = "FECHA_ALTA", nullable = true, insertable = true, updatable = true, length = 7, precision = 0)
    public Timestamp getFechaAlta() {
        return fechaAlta;
    }

    public void setFechaAlta(Timestamp fechaAlta) {
        this.fechaAlta = fechaAlta;
    }

    @Basic
    @Column(name = "FECHA_ACTUALIZA", nullable = true, insertable = true, updatable = true, length = 7, precision = 0)
    public Timestamp getFechaActualiza() {
        return fechaActualiza;
    }

    public void setFechaActualiza(Timestamp fechaActualiza) {
        this.fechaActualiza = fechaActualiza;
    }

    @Basic
    @Column(name = "FK_CAT_ESTATUS", nullable = false, insertable = true, updatable = true, length = 1, precision = 0)
    public BigInteger getFkCatEstatus() {
        return fkCatEstatus;
    }

    public void setFkCatEstatus(BigInteger fkCatEstatus) {
        this.fkCatEstatus = fkCatEstatus;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        TblCatRolEntity that = (TblCatRolEntity) o;

        if (descRol != null ? !descRol.equals(that.descRol) : that.descRol != null) return false;
        if (fechaActualiza != null ? !fechaActualiza.equals(that.fechaActualiza) : that.fechaActualiza != null)
            return false;
        if (fechaAlta != null ? !fechaAlta.equals(that.fechaAlta) : that.fechaAlta != null) return false;
        if (fkCatEstatus != null ? !fkCatEstatus.equals(that.fkCatEstatus) : that.fkCatEstatus != null) return false;
        if (pkCatRol != null ? !pkCatRol.equals(that.pkCatRol) : that.pkCatRol != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = pkCatRol != null ? pkCatRol.hashCode() : 0;
        result = 31 * result + (descRol != null ? descRol.hashCode() : 0);
        result = 31 * result + (fechaAlta != null ? fechaAlta.hashCode() : 0);
        result = 31 * result + (fechaActualiza != null ? fechaActualiza.hashCode() : 0);
        result = 31 * result + (fkCatEstatus != null ? fkCatEstatus.hashCode() : 0);
        return result;
    }

    @ManyToOne
    @JoinColumn(name = "FK_CAT_ESTATUS", referencedColumnName = "PK_CAT_ESTATUS", nullable = false)
    public TblCatEstatusEntity getTblCatEstatusByFkCatEstatus() {
        return tblCatEstatusByFkCatEstatus;
    }

    public void setTblCatEstatusByFkCatEstatus(TblCatEstatusEntity tblCatEstatusByFkCatEstatus) {
        this.tblCatEstatusByFkCatEstatus = tblCatEstatusByFkCatEstatus;
    }

    @OneToMany(mappedBy = "tblCatRolByFkCatRol")
    public Collection<TblRelGrupoRolEntity> getTblRelGrupoRolsByPkCatRol() {
        return tblRelGrupoRolsByPkCatRol;
    }

    public void setTblRelGrupoRolsByPkCatRol(Collection<TblRelGrupoRolEntity> tblRelGrupoRolsByPkCatRol) {
        this.tblRelGrupoRolsByPkCatRol = tblRelGrupoRolsByPkCatRol;
    }
}
